import java.lang.reflect.Array;
import java.util.Arrays;

public class test_11_04 {

    public static void main(String[] args) {
        int[] array = {1,2,3,4};

        // 可以通过这个方法进行扩容   拷贝哪个  拷贝多长
        int[] ret = Arrays.copyOf(array,array.length);

    }

    public static void fun1(int[] array){
        array = new int[]{11,22,33,44};
        // 从这下面 都改变不了实参的值了
    }
    public static void fun2(int[] array){
        array[0] = 100;
    }
    public static void main4(String[] args) {
        int[] array1 = {1,2,3,4};
        fun1(array1);
        fun2(array1);
        System.out.println(Arrays.toString(array1));
    }

    public static void main3(String[] args) {
        int[] array1 = {1,2,3,4};
        int[] array2 = {11,22,33,44};
        array1 = array2;
        array1[0] = 1999;
        System.out.println(array1);
        System.out.println(array2);
    }

    public static void main2(String[] args) {
        int[] array1 = {1,2,3,4};
        array1[0] = 99;

        int[] array2 = array1;
        array2[0] = 100;
        System.out.println(array1);
        System.out.println(array2);
    }
    public static void main1(String[] args) {
       // 3种定义数组的方式
       int[] array1 = {1,2,3,4};
       int[] array2 = new int[]{1,2,3,4};
       int[] array3 = new int[4];

       // 空指针异常
       int[] array4 = null;
        System.out.println(array4.length);
    }
}
